from django.urls import path
from rest_framework.urlpatterns import format_suffix_patterns
from snippets import views  # 假设views.py中定义了SnippetsList和UserList视图

# API endpoints
urlpatterns = format_suffix_patterns([
    path('', views.api_root),  # 添加api_root视图作为API的入口点
    path('snippets/', views.SnippetList.as_view(), name='snippet-list'),
    path('snippets/<int:pk>/', views.SnippetDetail.as_view(), name='snippet-detail'),
    path('users/', views.UserList.as_view(), name='user-list'),
    path('users/<int:pk>/', views.UserDetail.as_view(), name='user-detail'),
])

# 注意：实际应用中可能还有其他路径定义，如snippet和user的详细视图等，此处省略以保持示例简洁

# $  python manage.py createsuperuser
# $ http GET http://localhost:8000/users/

# $ http -a xiongmc:123456 POST http://127.0.0.1:8000/snippets/ code="print(789)" title=test
# $ http GET http://localhost:8000/snippets/


